<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-06-17 11:11:39
 * @LastEditors: charles
 * @LastEditTime: 2021-06-17 11:19:11
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let obj = {
      name:"terry",
      age:12,
      gender:"male"
    }
    // 方案1
    console.log(obj.name);
    // 方案2
    let name = "name";
    console.log(obj[name]);

    // 检测指定属性是否在对象中
    console.log('name' in obj);
    console.log('telephone' in obj);
    for(var k in obj){
      let v = obj[k];
      console.log(k,v);
    }
  </script>
</body>
</html>